Model for joint multispecies distributions

Using real data. For more infromation on how these data were obtain go to: http://panthera:8888/notebooks/external_plugins/paper3code/%5BD.E%5DCell%20Extractor.ipynb

Load libraries

Data Needed

Change working directory to a hierarchy such that the folder 'data' is a sibling node

Data preprocessing , Remove islands

Fitting the model

Reload the module just to check if the updated version was alright

Continue sampling after burnin

print(fit_continue.stansummary(pars='beta')) print(fit_continue.stansummary(pars='alpha')) print(fit_continue.stansummary(pars='alpha_car')) print(fit_continue.stansummary(pars='tau'))

Visualisation

Saving the model, its posterior sample

Depending on the model, generating a convergent posterior sample could take several hours. In this case, it is recommended to save the model for later use. To do this, we can pickle the 'fit3' object and save it to disk. Afterwards, we can load this pickled object for later analysis, plotting and generating further samples.

It is recommended to use the same machine for generating the posterior sample (and compiled model) and for loading the pickled object. If the model is compiled in a computer with a different architecture (and operative system) that the one intending to load the pickled object, the unpickling function will fail.

import pickle _file = "/outputs/presence_only_models/multispecies_model.pkl" with open(_file,"wb") as f: %time pickle.dump([multispecies_model,fit3],f,protocol=-1)

Load the pickled object

Load the summary statistics